#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2016 lizongzhe 
#
# Distributed under terms of the MIT license.

from esr_parser.models import KeywordTask, ProductListTask
from Task.models import Task
from rest_framework import serializers



class TaskSerializer(serializers.HyperlinkedModelSerializer):
    url = serializers.HyperlinkedIdentityField(view_name='task-detail')
    class Meta:
        model = Task
        fields = ('id', 'module', 'name', 'url', 'live')

class KeywordTaskSerializer(serializers.HyperlinkedModelSerializer):
    tasks = TaskSerializer(many=True, read_only=True)
    class Meta:
        model = KeywordTask



class ProductListTaskSerializer(serializers.HyperlinkedModelSerializer):
    task = TaskSerializer(read_only=True)
    class Meta:
        model = ProductListTask


